
import {observable,action,toJS} from "mobx"
import { ajax } from "../api"

class UserInfo{
    @observable user={}
    @observable collapsed=false

    @action changeUser = (cb)=>{
        ajax.getuserinfo().then(res=>{
            if(res.code==200){
                this.user={
                    ...res.result
                }
                localStorage.setItem("phone",res.result.phone)
                cb&&cb()
            }
        })
    }

    @action qingkong = (payload)=>{
        this.user=payload
    }

    @action changeUserOne = (payload) =>{
        this.user={
            ...toJS(this.user),
            ...payload
        }
    }

    @action changeCollapsed = ()=>{
        this.collapsed=!this.collapsed
    }
}

export default new UserInfo()